#include<stdio.h>
#include<string.h>                                                              
#include<unistd.h>
#include<pthread.h>
#include<fcntl.h>
#include<sys/stat.h>

int main(int argc, char* argv[])
{
    mkfifo("./fifo",0644);
    int fd = open("./fifo",O_RDWR);
    int pid = fork();

    if(pid==0)
    {
        write(fd,"hello fifo",10);
    }
    else
    {
        char buf[1024];
        int read_count = read(fd,buf,sizeof(buf));
        buf[read_count]='\0';
        printf("read_count = %d,buf = %s\n",read_count,buf);
    }
    return 0;
}


